package com.example.byteinputstream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class ByteStreamDemo6 {
    public static void main(String[] args) throws IOException {

        //开始时间
        long start = System.currentTimeMillis();

        //创建对象
        FileInputStream fis = new FileInputStream("src/com/example/file/a.txt");
        FileOutputStream fos = new FileOutputStream("src/com/example/file/b.txt");

        //拷贝文件
        byte[] buf = new byte[16];

        int read = fis.read(buf);
        while (read != -1) {
            fos.write(buf, 0, read);
            read = fis.read(buf);
        }

        //释放资源
        fos.close();
        fis.close();

        //结束时间
        long end = System.currentTimeMillis();

        System.out.println(end - start);

    }
}
